﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using OASys.Biz.BizAccess;
using OASys.Web.Base;
using OASys.Web.Models;
using OASys.Entity;
using OASys.Enum;
using Project.Common;
using Project.Web.Base;
using Project.Web.Base.Utility;

namespace OASys.Web.Controllers
{
    public class TreePageController : BaseController
    {
        private BizUTOrgDepartment bizUTOrgDepartment;
        private BizSysRole bizSysRole;
        private BizSysCodeType bizSysCodeType;
        private BizSysMenu bizSysMenu;
        private BizSysUserType bizSysUserType;
        private BizUTOrganization bizUTOrganization;

        public ActionResult Index()
        {
            return View();
        }
        /// <summary>
        /// 用户类别管理
        /// 作者：尤啸
        /// 时间：2012-06-27
        /// </summary>
        /// <returns></returns>
        public ActionResult SysUserTypeManageIndex()
        {
            var list = bizSysUserType.List(x => x.Name, EnumOrder.ASC);
            SelectList sysUserTypeCollenction = SelectListHelper.ComposeSelectListFromCollect(list, x => x.ID, x => x.Name);
            return View(sysUserTypeCollenction);
        }
        /// <summary>
        /// 菜单管理
        /// 作者：尤啸
        /// 时间：2012-06-27
        /// </summary>
        /// <returns></returns>
        public ActionResult SysMenuManageIndex()
        {
            ViewBag.FrameUrl = "/ModuleSys/SysMenuManage/Index";
            var treeDataSources = bizSysMenu.List(x => x.OrderIndex, EnumOrder.ASC);
            return View(treeDataSources);
        }

        /// <summary>
        /// 组织机构管理框架
        /// 作者：尤啸
        /// 时间：2012-06-27
        /// </summary>
        public ActionResult SysOrgDepartmentManageIndex()
        {
            ViewBag.FrameUrl = "/ModuleSys/SysOrgDepartmentManage/Index";
            ModelTreePageSysOrganizationManageIndex modelObj = new ModelTreePageSysOrganizationManageIndex();
            modelObj.RetriveData();
            return View(modelObj);
        }

        /// <summary>
        /// 用户管理框架
        /// 作者：尤啸
        /// 时间：2012-06-27
        /// </summary>
        public ActionResult SysUserManageIndex(ModelTreePageUTOrgDepartmentManageIndex model)
        {
            ViewBag.FrameUrl = "/ModuleSys/SysUserManage/Index";
            model.RetriveData();
            return View(model);
        }

        /// <summary>
        /// 角色管理框架
        /// 作者：尤啸
        /// 时间：2012-06-27
        /// </summary>
        public ActionResult SysRoleManageIndex()
        {
            var list = bizSysRole.List(x => x.CreateTime, EnumOrder.ASC);
            SelectList sysRoleCollection = SelectListHelper.ComposeSelectListFromCollect(list, x => x.ID, x => x.RoleName);
            return View(sysRoleCollection);
        }

        /// <summary>
        /// 权限管理框架
        /// 作者：尤啸
        /// 时间：2012-06-27
        /// </summary>
        public ActionResult SysUserRightIndex(ModelTreePageSysUserRightIndex model)
        {
            //ViewBag.FrameUrl = "/ModuleSys/SysUserRightManage/Index";
            //ModelTreePageSysUserRightIndex model = new ModelTreePageSysUserRightIndex();
            model.RetriveData();
            return View(model);
        }

        /// <summary>
        /// 参数设置框架
        /// 作者：尤啸
        /// 时间：2012-06-27
        /// </summary>
        public ActionResult ParameterSettingsIndex()
        {
            //ViewBag.FrameUrl = "/ModuleSys/SysUserRightManage/Index";
            IList<SysCodeType> sysCodeTypeCollection = bizSysCodeType.ListBy(x => x.Class == (int)EnumCodeTypeClass.可维护, x => x.SortOrder, EnumOrder.ASC);
            return View(sysCodeTypeCollection);
        }

    }
}
